home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / bbs / Hydra11s.lha / HBBS / Source / Doors_System / ConfirmUL / Main.C < prev    next >
C/C++ Source or Header  |  1996-10-31  |  4KB  |  192 lines

  1. /*
  2.  
  3.   ConfirmUL
  4.   ---------
  5.  
  6.   Asks user wehter the file that was just uploaded is a) a sysop file
  7.   or b) an incorrect upload
  8.   Also checks the FileID for a / at the start, if one is found it's a
  9.   sysop file..
  10.  
  11.   options
  12.   =======
  13.  
  14.     argv[x]
  15.     -------
  16.  
  17.     2 filename (check <nodelocation+"/WORK/"+filename+".DIZ" for the file id..
  18.  
  19.   returns
  20.   -------
  21.  
  22.   SYSOP | INCORRECT
  23.  
  24. */
  25.  
  26. #include <exec/types.h>
  27. #include <exec/memory.h>
  28. #include <dos/dos.h>
  29. #include <clib/exec_protos.h>
  30. #include <clib/dos_protos.h>
  31. #include <clib/alib_protos.h>
  32.  
  33. #include <stdlib.h>
  34. #include <string.h>
  35. #include <stdio.h>
  36. #include <ctype.h>
  37. #include <time.h>
  38.  
  39.  
  40. #ifdef __SASC
  41. int CXBRK(void) { return(0); }
  42. int _CXBRK(void) { return(0); }
  43. void chkabort(void) {}
  44. #endif
  45.  
  46. #include <HBBS/ANSI_Codes.h>
  47. #include <HBBS/Defines.h>
  48. #include <HBBS/types.h>
  49. #include <HBBS/structures.h>
  50. #include <HBBS/hbbscommon_protos.h>
  51. #include <HBBS/hbbscommon_pragmas.h>
  52. #include <HBBS/Hbbsnode_protos.h>
  53. #include <HBBS/Hbbsnode_pragmas.h>
  54. #include <HBBS/release.h>
  55. char *versionstr="$VER: ConfirmUL "RELEASE_STR;
  56.  
  57. struct Library *HBBSCommonBase=NULL;
  58. struct Library *HBBSNodeBase=NULL;
  59.  
  60. struct BBSGlobalData *BBSGlobal=NULL;
  61. struct NodeData *N_ND=NULL;
  62. int N_NodeNum=-1;
  63. char outstr[1024]; // temp string for displaying text..
  64.  
  65. static VOID cleanup(ULONG num)
  66. {
  67.   if (HBBSNodeBase)
  68.   {
  69.     HBBS_CleanUpDoor();
  70.     CloseLibrary (HBBSNodeBase);
  71.   }
  72.  
  73.   if (HBBSCommonBase)
  74.   {
  75.     HBBS_CleanUpCommon();
  76.     CloseLibrary (HBBSCommonBase);
  77.   }
  78.  
  79.   if (num) printf("Door Error = %d\n",num);
  80.  
  81.   exit(0);
  82. }
  83.  
  84. static VOID init(char *name)
  85. {
  86.   if(!(HBBSCommonBase = OpenLibrary("HBBSCommon.library",0)))
  87.   {
  88.     cleanup(1);
  89.   }
  90.  
  91.   if (!(HBBS_InitCommon()))
  92.   {
  93.     cleanup(2);
  94.   }
  95.  
  96.   if(!(HBBSNodeBase = OpenLibrary("HBBSNode.library",0)))
  97.   {
  98.     cleanup(3);
  99.   }
  100.  
  101.   if (!(HBBS_InitDoor(N_NodeNum,name)))
  102.   {
  103.     cleanup(4);
  104.   }
  105.   SetProgramName(name);
  106. }
  107.  
  108. void DoorMain(int argc,char *argv[])
  109. {
  110.   BPTR FH;
  111.   BOOL Continue=FALSE;
  112.   BOOL SysopFile=FALSE;
  113.   UBYTE buffer;
  114.  
  115. //  DOOR_WriteText("\r\n-=[  Hydra ConfirmUL V1.0  ]=- ========= -=[  (C) 1995 Deluxe Software Ltd  ]=-\r\n\r\n");
  116.  
  117. //  sprintf(outstr,"args %d\r\n",argc);
  118. //  DOOR_WriteText(outstr);
  119.  
  120.   if (argc==3)
  121.   {
  122.     sprintf(outstr,"%sWork/%s.DIZ",N_ND->NodeLocation,argv[2]);
  123.     if (FH=Open(outstr,MODE_OLDFILE))
  124.     {
  125.       if (Read(FH,&buffer,1))
  126.       {
  127.         if (buffer=='/') SysopFile=TRUE;
  128.       }
  129.       Close(FH);
  130.     }
  131.  
  132.     if (!SysopFile)
  133.     {
  134.       do
  135.       {
  136.         Continue=TRUE;
  137.         strcpy(N_ND->CharsAllowed,"SsIiNn");
  138.         DOOR_MenuPrompt(ANSI_RESET "Is this file a [S]ysop File, an [I]ncorrect Upload or [N]ormal > ",'N');
  139. //        DOOR_WriteText(ANSI_RESET ANSI_FG_WHITE "Is this file a [" ANSI_FG_PURPLE "S" ANSI_FG_WHITE "]ysop File, an [" ANSI_FG_PURPLE "I" ANSI_FG_WHITE "]ncorrect Upload or just [" ANSI_FG_PURPLE ANSI_BOLD "N" ANSI_RESET ANSI_FG_WHITE "]ormal ");
  140.         DOOR_GetLine(GL_EDIT|GL_USECHARS|GL_IMMEDIATE,'\0',1,3,NULL);
  141.         if (N_ND->OnlineStatus==OS_ONLINE)
  142.         {
  143.           switch(toupper(N_ND->CurrentLine[0]))
  144.           {
  145.             case 0:
  146.             case 'N':
  147.               DOOR_WriteText("Normal\r\n");
  148.               break;
  149.             case 'S':
  150.               DOOR_WriteText("Sysop\r\n");
  151.               SysopFile=TRUE;
  152.               break;
  153.             case 'I':
  154.               DOOR_WriteText("Incorrect\r\n");
  155.               DOOR_Return("INCORRECT");
  156.               break;
  157.             default:
  158.               Continue=FALSE;
  159.               break;
  160.           }
  161.         }
  162.       }
  163.       while (Continue==FALSE);
  164.     }
  165.     if (SysopFile)
  166.     {
  167.       DOOR_WriteText(ANSI_FG_WHITE ANSI_BOLD "Autodetected A SYSOP File.\r\n" ANSI_RESET);
  168.       DOOR_Return("SYSOP");
  169.     }
  170.   }
  171.   else DOOR_WriteText(ANSI_FG_RED ANSI_BOLD "Incorrect Parameters!\r\n");
  172. }
  173.  
  174. int main(int argc,char *argv[])
  175. {
  176.   if (sscanf(argv[1],"%d",&N_NodeNum)==0)
  177.   {
  178.     printf("Invalid/No Paramaters for door!\n");
  179.     exit (20);
  180.   }
  181.   init("ConfirmUL");
  182.  
  183.   if (BBSGlobal=HBBS_GimmeBBS())
  184.   {
  185.     if (N_ND=HBBS_NodeDataPtr(N_NodeNum)) // this should not fail in normal circumstances..
  186.     {
  187.       DoorMain(argc,argv);
  188.     }
  189.   }
  190.   cleanup(0);
  191. }
  192.